<?php
$loader->requireOnce("/lib/Calendar/Week.php");	
class C_WorkingCalendar extends Controller {
	
	var $current_day = '';
	var $current_mon = '';
	var $current_year = '';
	const START_WORKING_TIME = 7;
	
    function C_WorkingCalendar($template_mod = "general") {
        parent::Controller();
        $this->_db = $GLOBALS['frame']['adodb']['db'];   
    	if (Celini::getCurrentController() == 'WorkingCalendar') {
			$menu =& Menu::getInstance();
			$menu->currentSection = 'patient';
		}
		$current_date = getdate();
		$this->current_day = $current_date['mday'];
		$this->current_mon = $current_date['mon'];
		$this->current_year = $current_date['year'];
        $this->template_mod = $template_mod;        
        $this->view->path = 'working_calendar';
    }
    
    public function actionViewCalendar(){
		$me =& Me::getInstance();
 		$current_person_id = $me->get_person_id();
 		$exist = Celini::newORDO('CalendarRelationship')->checkExist($current_person_id);
 		if($exist[0]['sum'] > 0){
    		return $this->view->render("view_create.html");
 		}
 		return $this->view->render("view.html");
    }
    
    public function actionManagement(){
    	return $this->view->render("management.html");
    }
    
    public function actionCreateCalendarAjax(){
    	$me =& Me::getInstance();
    	$current_person_id = $me->get_person_id();
    	$relational_person_list = Celini::newORDO('CalendarRelationship')->getRelationalPersonName($current_person_id);
    	$this->assign('employee_list', $relational_person_list);
    	return $this->view->render("create_calendar.html");
    }
    
    public function actionViewCalendarAjax(){
    	$employee_type_list = Celini::newORDO('EmployeeType')->getAll();
    	$this->assign('employee_type_list', $employee_type_list);
    	return $this->view->render("view_calendar.html");
    }
    
    public function actionGetCalendarTblAjax(){
  		if($_GET['year'] == ''){
  			$year = $this->current_year;
  			$mon = $this->current_mon;
  			$day = $this->current_day;
  		}else{
  			$year = $_GET['year'];
  			$mon = $_GET['mon'];
  			$day = $_GET['day'];
  		}
  		if($_GET['actionCalendar'] == 'edit'){
  			return $this->renderWeekEdit($_GET['personId'],$year, $mon, $day);
  		}else{
  			return $this->renderWeekView($_GET['personId'],$year, $mon, $day);
  		}
    }
    
	public function actionGetUserByEmployeeTypeAjax(){
 		if(!isset($_GET['employee_type_id']) || $_GET['employee_type_id'] =='' ) return;
 		$employee_list = Celini::newORDO('Employee')->getUserList(array($_GET['employee_type_id']));
 		$response = '';
 		if(isset($employee_list) && $employee_list != ''){
 			foreach($employee_list as $employee){ 			
 				$response .= "<option value='{$employee['person_id']}' >{$employee['name']}</option>";
 			}
 		}
 		return $response;
 	}
 	
 	public function actionSaveCalendarAjax(){
 		$me =& Me::getInstance();
 		$creator_id = $me->get_person_id();
 		$monday 	= array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
		$tuesday 	= array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
		$wednesday 	= array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
		$thursday 	= array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
		$friday 	= array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
		$saturday 	= array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
		$sunday 	= array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');
 		if (isset($_GET['mondayTime'])) {
 			$mondayGet = $_GET['mondayTime'];
	 		for($i = 0; $i < count($mondayGet); $i++){
				$monday[$mondayGet[$i]] = 1;
 			}
 		}
 		if (isset($_GET['tuesdayTime'])) {
 			$tuesdayGet = $_GET['tuesdayTime'];
	 		for($i = 0; $i < count($tuesdayGet); $i++){
				$tuesday[$tuesdayGet[$i]] = 1;
 			}
 		}
 		if (isset($_GET['wednesdayTime'])) {
 			$wednesdayGet = $_GET['wednesdayTime'];
	 		for($i = 0; $i < count($wednesdayGet); $i++){
				$wednesday[$wednesdayGet[$i]] = 1;
 			}
 		}
 		if (isset($_GET['thursdayTime'])) {
 			$thursdayGet = $_GET['thursdayTime'];
	 		for($i = 0; $i < count($thursdayGet); $i++){
				$thursday[$thursdayGet[$i]] = 1;
 			}
 		}
 		if (isset($_GET['fridayTime'])) {
 			$fridayGet = $_GET['fridayTime'];
	 		for($i = 0; $i < count($fridayGet); $i++){
				$friday[$fridayGet[$i]] = 1;
 			}
 		}
 		if (isset($_GET['saturdayTime'])) {
 			$saturdayGet = $_GET['saturdayTime'];
	 		for($i = 0; $i < count($saturdayGet); $i++){
				$saturday[$saturdayGet[$i]] = 1;
 			}
 		}
 		if (isset($_GET['sundayTime'])) {
 			$sundayGet = $_GET['sundayTime'];
	 		for($i = 0; $i < count($sundayGet); $i++){
				$sunday[$sundayGet[$i]] = 1;
 			}
 		}
 		$monday 	= implode('', $monday);
		$tuesday 	= implode('', $tuesday);
		$wednesday 	= implode('', $wednesday);
		$thursday 	= implode('', $thursday);
		$friday 	= implode('', $friday);
		$saturday 	= implode('', $saturday);
		$sunday 	= implode('', $sunday);
 		return Celini::newORDO('WorkingCalendar')->addCalendar($_GET['calendar_id'],
 			$creator_id, $_GET['startDate'], $_GET['endDate'], $_GET['personId'],
 			$monday, $tuesday, $wednesday, $thursday, $friday, $saturday, $sunday); 
 	}
 	
	private function renderWeekView($userId, $year, $month, $mday) {
		$searchDate = $year.'-'.$month.'-'.$mday;
		$result = Celini::newORDO('WorkingCalendar')->getCalendar($userId, $searchDate);
		$personName = Celini::newORDO('Person', $userId)->get('name');	
		if (!isset($result) || count($result) == 0) {
			$monday 	= str_split('000000000000',1);
			$tuesday 	= $monday;
			$wednesday 	= $monday;
			$thursday 	= $monday;
			$friday 	= $monday;
			$saturday 	= $monday;
			$sunday 	= $monday;
		} else {
			$monday 	= str_split($result[0]['monday'],1);
			$tuesday 	= str_split($result[0]['tuesday'],1);
			$wednesday 	= str_split($result[0]['wednesday'],1);
			$thursday 	= str_split($result[0]['thursday'],1);
			$friday 	= str_split($result[0]['friday'],1);
			$saturday 	= str_split($result[0]['saturday'],1);
			$sunday 	= str_split($result[0]['sunday'],1);
		}
		$adjacentDates = $this->getAdjacentWeeks($year, $month, $mday);
		$weekDays = new Calendar_Week($year, $month, $mday);
		$weekDays->build();
		$day = $weekDays->fetchAll();
		$body = "";
		for ($i = 0; $i < 12; $i++) {
			$body .= "<tr>
					      <td  style='border-left: 1px solid #AAAEB6; text-align: left'>{$this->getTimePeriod($i, self::START_WORKING_TIME)}</td>
					      <td class='workingType_$monday[$i]'>&nbsp;</td>
					      <td class='workingType_$tuesday[$i]'>&nbsp;</td>
					      <td class='workingType_$wednesday[$i]'>&nbsp;</td>
					      <td class='workingType_$thursday[$i]'>&nbsp;</td>
					      <td class='workingType_$friday[$i]'>&nbsp;</td>
					      <td class='workingType_$saturday[$i]'>&nbsp;</td>
					      <td class='workingType_$sunday[$i]'>&nbsp;</td>
					  </tr>";
		}
		$body .= "<tr><td class='editNote'>&nbsp;</td>";
		$isToday = false;
		for ($i = 1; $i <= 7; $i++) {
			if ($day[$i]->isToday()) {
				$isToday = true;
			}
			$day[$i] = $day[$i]->toArray();
			$result = Celini::newORDO('WorkingCalendarNote')->getNote($userId, "{$day[$i]['year']}-{$day[$i]['month']}-{$day[$i]['day']}");
			if ($result['id'] > 0) {
				$body .= "<td class='editNote'><a href=\"javascript:viewNote({$result['id']})\"><img src='../images/note.png' /></a></td>";
			} else {
				$body .= "<td class='editNote'>&nbsp;</td>";
			}
		}
		$body .= "</tr>";
		$today = date('D');
		$classes = $this->getTodayClass($isToday, 'caption', 'today');
		$from = L10nHelper::renderDateTime($day[1]['year']."-".$day[1]['month']."-".$day[1]['day']);				
		$to=L10nHelper::renderDateTime($day[7]['year']."-".$day[7]['month']."-".$day[7]['day']);		
		$html = "<table cellspacing='0' cellpadding='0' class='calGrid' style='width: 100%'>
					<tr>
						<td class='calHeader' style='border-left: 1px solid #777'>
							<a href='javascript:renderWeek(".'"view"'.",{$adjacentDates['prevWeek']['year']}, {$adjacentDates['prevWeek']['mon']}, {$adjacentDates['prevWeek']['mday']});' title='".L10nHelper::_("Previous week")."'>&lt;&lt;</a>&nbsp;&nbsp;&nbsp;
							<a href='javascript:renderWeek(".'"view"'.",{$adjacentDates['nextWeek']['year']}, {$adjacentDates['nextWeek']['mon']}, {$adjacentDates['nextWeek']['mday']});' title='".L10nHelper::_("Next week")."'>&gt;&gt;</a>
						</td>
						<td class='calHeader' colspan='6'>$personName - ".L10nHelper::_("Week")." $from - $to</td>
						<td class='calHeader' style='border-right: 1px solid #777'>
							<a href='javascript:renderWeek(".'"view"'.",{$this->current_year}, {$this->current_mon}, {$this->current_day})' title='".L10nHelper::_("Present week")."'>".L10nHelper::_("Present_1")."</a>
						</td>
					</tr>
					<tr>
						<td class='caption' style='border-left: 1px solid #AAAEB6'>".L10nHelper::_("Time")."</td>
						<td class='{$classes['Mon']}' style='width:110px'>".L10nHelper::_("Mon")."</td>
						<td class='{$classes['Tue']}' style='width:110px'>".L10nHelper::_("Tue")."</td>
						<td class='{$classes['Wed']}' style='width:110px'>".L10nHelper::_("Wed")."</td>
						<td class='{$classes['Thu']}' style='width:110px'>".L10nHelper::_("Thu")."</td>
						<td class='{$classes['Fri']}' style='width:110px'>".L10nHelper::_("Fri")."</td>
						<td class='{$classes['Sat']}' style='width:110px'>".L10nHelper::_("Sat")."</td>
						<td class='{$classes['Sun']}' style='width:110px; border-right: 1px solid #AAAEB6'>".L10nHelper::_("Sun")."</td>
					</tr>";
		return $html . $body . "</table>";
	}
	
	private function renderWeekEdit($userId, $year, $month, $mday) {
		$searchDate = $year.'-'.$month.'-'.$mday;
		$result = Celini::newORDO('WorkingCalendar')->getCalendar($userId, $searchDate);
		$personName = Celini::newORDO('Person', $userId)->get('name');
		if (!isset($result) || count($result) == 0) {
			$monday 	= str_split('000000000000',1);
			$tuesday 	= $monday;
			$wednesday 	= $monday;
			$thursday 	= $monday;
			$friday 	= $monday;
			$saturday 	= $monday;
			$sunday 	= $monday;
			$calendarId = '';
		}else{
			$monday 	= str_split($result[0]['monday'],1);
			$tuesday 	= str_split($result[0]['tuesday'],1);
			$wednesday 	= str_split($result[0]['wednesday'],1);
			$thursday 	= str_split($result[0]['thursday'],1);
			$friday 	= str_split($result[0]['friday'],1);
			$saturday 	= str_split($result[0]['saturday'],1);
			$sunday 	= str_split($result[0]['sunday'],1);
			$calendarId = $result[0]['calendar_id'];	
		}
		$mondayInput 	= array('', '', '', '', '', '', '', '', '', '', '', '');
		$tuesdayInput 	= array('', '', '', '', '', '', '', '', '', '', '', '');
		$wednesdayInput = array('', '', '', '', '', '', '', '', '', '', '', '');
		$thursdayInput 	= array('', '', '', '', '', '', '', '', '', '', '', '');
		$fridayInput 	= array('', '', '', '', '', '', '', '', '', '', '', '');
		$saturdayInput 	= array('', '', '', '', '', '', '', '', '', '', '', '');
		$sundayInput 	= array('', '', '', '', '', '', '', '', '', '', '', '');
		
		for($i = 0; $i < count($monday); $i++){	
			$mondayChecked = '';
			if($monday[$i] == '1'){
				$mondayChecked = "checked='checked'";	 
			}
			$mondayInput[$i] = "<input type='checkbox' id='mondayTime_$i' name='mondayTime[]' $mondayChecked value='$i'>";
			
			$tuesdayChecked = '';
			if($tuesday[$i] == '1'){
				$tuesdayChecked = "checked='checked'";	 
			}
			$tuesdayInput[$i] = "<input type='checkbox' id='tuesdayTime_$i' name='tuesdayTime[]' $tuesdayChecked value='$i'>";
			
			$wednesdayChecked = '';
			if($wednesday[$i] == '1'){
				$wednesdayChecked = "checked='checked'";	 
			}
			$wednesdayInput[$i] = "<input type='checkbox' id='wednesdayTime_$i' name='wednesdayTime[]' $wednesdayChecked value='$i'>";
			
			$thursdayChecked = '';
			if($thursday[$i] == '1'){
				$thursdayChecked = "checked='checked'";	 
			}
			$thursdayInput[$i] = "<input type='checkbox' id='thursdayTime_$i' name='thursdayTime[]' $thursdayChecked value='$i'>";
			
			$fridayChecked = '';
			if($friday[$i] == '1'){
				$fridayChecked = "checked='checked'";	 
			}
			$fridayInput[$i] = "<input type='checkbox' id='fridayTime_$i' name='fridayTime[]' $fridayChecked value='$i'>";
			
			$saturdayChecked = '';
			if($saturday[$i] == '1'){
				$saturdayChecked = "checked='checked'";	 
			}
			$saturdayInput[$i] = "<input type='checkbox' id='saturdayTime_$i' name='saturdayTime[]' $saturdayChecked value='$i'>";
			
			$sundayChecked = '';
			if($sunday[$i] == '1'){
				$sundayChecked = "checked='checked'";	 
			}
			$sundayInput[$i] = "<input type='checkbox' id='sundayTime_$i' name='sundayTime[]' $sundayChecked value='$i'>";
		}
		$adjacentDates = $this->getAdjacentWeeks($year, $month, $mday);
		$weekDays = new Calendar_Week($year, $month, $mday);
		$weekDays->build();
		$day = $weekDays->fetchAll();
		$body = "";
		for ($i = 0; $i < 12; $i++) {
			$body .= "<tr>
					      <td  style='border-left: 1px solid #AAAEB6; text-align: left'>{$this->getTimePeriod($i, self::START_WORKING_TIME)}</td>
					      <td class='workingType_$monday[$i]'>$mondayInput[$i]</td>
					      <td class='workingType_$tuesday[$i]'>$tuesdayInput[$i]</td>
					      <td class='workingType_$wednesday[$i]'>$wednesdayInput[$i]</td>
					      <td class='workingType_$thursday[$i]'>$thursdayInput[$i]</td>
					      <td class='workingType_$friday[$i]'>$fridayInput[$i]</td>
					      <td class='workingType_$saturday[$i]'>$saturdayInput[$i]</td>
					      <td class='workingType_$sunday[$i]'>$sundayInput[$i]</td>
					  </tr>";
		}
		$body .= "<tr>
				      <td style='border-left: 1px solid #AAAEB6; text-align: left'>&nbsp;</td>
				      <td><input type='checkbox' id='mondayController' onclick=\"javascript:toggleCheck('mondayController', 'mondayTime');\"/></td>
				      <td><input type='checkbox' id='tuesdayController' onclick=\"javascript:toggleCheck('tuesdayController', 'tuesdayTime');\"/></td>
				      <td><input type='checkbox' id='wednesdayController' onclick=\"javascript:toggleCheck('wednesdayController', 'wednesdayTime');\"/></td>
				      <td><input type='checkbox' id='thursdayController' onclick=\"javascript:toggleCheck('thursdayController', 'thursdayTime');\"/></td>
				      <td><input type='checkbox' id='fridayController' onclick=\"javascript:toggleCheck('fridayController', 'fridayTime');\"/></td>
				      <td><input type='checkbox' id='saturdayController' onclick=\"javascript:toggleCheck('saturdayController', 'saturdayTime');\"/></td>
				      <td><input type='checkbox' id='sundayController' onclick=\"javascript:toggleCheck('sundayController', 'sundayTime');\"/></td>
				  </tr>
				  <tr>
				  	  <td class='editNote'>&nbsp;</td>";
		$isToday = false;
		for ($i = 1; $i <= 7; $i++) {
			if ($day[$i]->isToday()) {
				$isToday = true;
			}
			$day[$i] = $day[$i]->toArray();
			$body .= "<td class='editNote'><a href=\"javascript:editNote($userId, '{$day[$i]['year']}-{$day[$i]['month']}-{$day[$i]['day']}')\"><img src='../images/note.png' /></a></td>";
		}
		$body .= "</tr>";
		$classes = $this->getTodayClass($isToday, 'caption', 'today');
		$from = L10nHelper::renderDateTime($day[1]['year']."-".$day[1]['month']."-".$day[1]['day']);				
		$to=L10nHelper::renderDateTime($day[7]['year']."-".$day[7]['month']."-".$day[7]['day']);		
		
		$html = "<input type='hidden' id='startDate' name='startDate' value='{$day[1]['year']}-{$day[1]['month']}-{$day[1]['day']}'>
				 <input type='hidden' id='endDate' name='endDate' value='{$day[7]['year']}-{$day[7]['month']}-{$day[7]['day']}'>
				 <input type='hidden' id='calendar_id' name='calendar_id' value='$calendarId'>
				 <table cellspacing='0' cellpadding='0' class='calGrid' style='width: 100%'>
					<tr>
						<td class='calHeader' style='border-left: 1px solid #777'>
							<a href='javascript:renderWeek(".'"edit"'.",{$adjacentDates['prevWeek']['year']}, {$adjacentDates['prevWeek']['mon']}, {$adjacentDates['prevWeek']['mday']});' title='".L10nHelper::_("Previous week")."'>&lt;&lt;</a>&nbsp;&nbsp;&nbsp;
							<a href='javascript:renderWeek(".'"edit"'.",{$adjacentDates['nextWeek']['year']}, {$adjacentDates['nextWeek']['mon']}, {$adjacentDates['nextWeek']['mday']});' title='".L10nHelper::_("Next week")."'>&gt;&gt;</a>
						</td>
						<td class='calHeader' colspan='6'>$personName - ".L10nHelper::_("Week")." $from - $to</td>
						<td class='calHeader' style='border-right: 1px solid #777'>
							<a href='javascript:renderWeek(".'"edit"'.",{$this->current_year}, {$this->current_mon}, {$this->current_day})' title='".L10nHelper::_("Present week")."'>".L10nHelper::_("Present_1")."</a>
						</td>
					</tr>
					<tr>
						<td class='caption' style='border-left: 1px solid #AAAEB6'>".L10nHelper::_("Time")."</td>
						<td class='{$classes['Mon']}' style='width:110px'>".L10nHelper::_("Mon")."</td>
						<td class='{$classes['Tue']}' style='width:110px'>".L10nHelper::_("Tue")."</td>
						<td class='{$classes['Wed']}' style='width:110px'>".L10nHelper::_("Wed")."</td>
						<td class='{$classes['Thu']}' style='width:110px'>".L10nHelper::_("Thu")."</td>
						<td class='{$classes['Fri']}' style='width:110px'>".L10nHelper::_("Fri")."</td>
						<td class='{$classes['Sat']}' style='width:110px'>".L10nHelper::_("Sat")."</td>
						<td class='{$classes['Sun']}' style='width:110px; border-right: 1px solid #AAAEB6'>".L10nHelper::_("Sun")."</td>
					</tr>";
		return $html . $body . "</table>";
	}
	
	private function getAdjacentWeeks($year, $month, $mday) {
		$curWeek = mktime(0, 0, 0, $month, $mday, $year);
		$dates['nextWeek'] = getdate($curWeek + 86400*7);
		$dates['prevWeek'] = getdate($curWeek - 86400*7);
		return $dates;
	}
	
	public function actionMappingRelationshipAjax(){
 		$employee_type_list = Celini::newORDO('EmployeeType')->getAll();
 		$nursing = EmployeeType::NURSING_ID;
 		$doctor = EmployeeType::DOCTOR_ID;
 		$this->assign('nursing', $nursing);
 		$this->assign('doctor', $doctor);
 		$this->assign('employee_type_list',$employee_type_list);
 		return $this->view->render('mapping_relationship.html');
 	}
	
	public function actionGetRelationalUserAjax(){
 		$user_list = Celini::newORDO('CalendarRelationship')->getRelationalPerson($_GET['employeeId']);
 		$response = '';
 		if(isset($user_list) && $user_list != ''){
 			foreach($user_list as $user){
 				$response .= "<tr id='{$user['relational_person_id']}_row'>
 								<td class='first'>{$user['name']}</td>
								<td>{$user['employee_type']}</td>
								<td class='last'><a href='javascript:removeUser({$user['relational_person_id']});'>".L10nHelper::_("Unselect")."</a></td>
							</tr>"; 
 			}
 		}
 		return $response;
 	}
 	
	public function actionAddUserToRelationshipAjax(){
 		return Celini::newORDO('CalendarRelationship')->addUser($_GET['personId'], $_GET['relational_personId']);
 	}
 	
	public function actionRemoveUserFromRelationshipAjax(){
 		Celini::newORDO('CalendarRelationship')->removeUser($_GET['personId'], $_GET['relational_personId']);
 		return;
 	}
 	
	public function actionGetEmployeeToAddAjax(){
 		$personId = $_GET['personId'];
 		$employeeTypeId = $_GET['employeeTypeId'];
		$employee_list = Celini::newORDO('Employee')->getEmployeeToAdd($employeeTypeId);
		$relational_person_list = Celini::newORDO('CalendarRelationship')->getRelationalPersonId($personId);
		array_push($relational_person_list, $personId);
		return $this->buildSearchResult($employee_list, $relational_person_list);				
 	}
 	
 	public function actionGetNoteAjax() {
 		return json_encode(Celini::newORDO('WorkingCalendarNote')->getNote($_GET['personId'], $_GET['date']));
 	}
 	
 	public function actionCreateNewNoteAjax() {
 		return Celini::newORDO('WorkingCalendarNote')->addNewNote($_POST['personId'], $_POST['date'], $_POST['note']);
 	}
 	
 	public function actionUpdateNoteAjax() {
 		return Celini::newORDO('WorkingCalendarNote')->updateNewNote($_POST['noteId'], $_POST['note']);
 	}
 	
	public function actionDeleteNoteAjax() {
 		return Celini::newORDO('WorkingCalendarNote')->deleteNote($_GET['noteId']);
 	}
 	
 	public function actionViewNoteAjax() {
 		return nl2br(Celini::newORDO('WorkingCalendarNote')->getNoteById($_GET['noteId']));
 	}
 	
 	private function buildSearchResult($user_list, $relational_person_list){
 		$response = '';
 		if(isset($user_list) && $user_list!= ''){
 			$i = 1;
	 		foreach($user_list as $user){
	 			if(!in_array($user['person_id'], $relational_person_list, true) ){
	 				$response .= "<tr id='{$i}_row'>
								<td class='first'><span id='{$user['person_id']}_name_span'>{$user['name']}</span></td>
								<td class='last' align='center'><a href='javascript:addUser({$user['person_id']},$i);'>".L10nHelper::_("Select")."</a></td>
								</tr>";
					$i++;
	 			}
				
			}
 		}
		return $response;		
 	}
 	
 	private function getTimePeriod($i, $offset) {
 		$i = $i + $offset;
 		if ($i > 12) {
 			$i -= 12;
 		}
 		$j = $i + 1;
 		if ($j > 12) {
 			$j -= 12;
 		}
 		return $i . 'h - ' . $j . 'h';
 	}
 	
 	private function getTodayClass($isToday, $baseClass, $additionalClass) {
 		$classes = array (
 			'Mon' => $baseClass,
	 		'Tue' => $baseClass,
	 		'Wed' => $baseClass,
	 		'Thu' => $baseClass,
	 		'Fri' => $baseClass,
	 		'Sat' => $baseClass,
	 		'Sun' => $baseClass,
 		);
 		if ($isToday) {
 			$today = date('D');
 			$classes[$today] .= ' ' . $additionalClass;
 		}
 		return $classes;
 	}	
}
?>